/**
 * list.h
 **/

#ifndef LIST_H
#define LIST_H

#define IDC_MAIN_SELECT 				10001
#define IDC_MAIN_TOOL					10002
#define IDC_MAIN_STATUS					10003
#define IDC_MAIN_EDIT					10004

#define IDC_BLACK                       20001
#define IDC_BLUE                        20002
#define IDC_GREEN                       20003
#define IDC_CYAN                        20004
#define IDC_RED                         20005
#define IDC_MAGENTA                     20006
#define IDC_YELLOW                      20007
#define IDC_WHITE                       20008

#define ID_DRAW_LINE                    30001
#define ID_DRAW_SQUARE                  30002
#define ID_DRAW_ELLIPSE                 30003

#define ID_CLEAR                        40001
#define ID_FILE_SAVEAS                  40002
#define ID_FILE_OPEN                    40013
#define ID_FILL_SHAPE                   40004
#define ID_EMPTY_SHAPE                  40005
#define ID_UNDO                         40006
#define ID_REDO                         40007
#define ID_EXIT                         40008

#define ID_COLOR_FRAME                  41001 
#define ID_CHOOSE_COLOR                 41002  
#define ID_CHOOSE_SHAPE                 41003

/**
 * Define a structure for linked list elements
 **/

typedef struct ListElmt_ {
   
    void *data;
    struct ListElmt_ *next;

} ListElmt;

/**
 * Define a structure for linked lists
 **/

typedef struct List_ {
    
    int size;
    
    int (*match)(const void *key1, const void *key2);
    void (*destroy)(void *data);

    ListElmt *head;
    ListElmt *tail;

} List;

/**
 * Public Interface
 **/

void list_init(List *list, void (*destroy)(void *data));

void list_destroy(List *list);

int list_ins_next(List *list, ListElmt *element, const void *data);

int list_rem_next(List *list, ListElmt *element, void **data);

#define list_size(list) ((list)->size)

#define list_head(list) ((list)->head)

#define list_tail(list) ((list)->tail)

#define list_is_head(list, element) ((element) == (list)->head ? 1 : 0)

#define list_is_tail(list, elememt) ((element) == (list)->tail ? 1 : 0)

#define list_data(element) ((element)->data)

#define list_next(element) ((element)->next)

#endif